<%@ page language="java" contentType="text/html; charset=UTF-8"  
    pageEncoding="UTF-8"%>  
<%@ page import="javax.sql.rowset.WebRowSet" %>   
<%@ page import="java.sql.*" %>  
<!DOCTYPE html>  
<html>  
<head>  
<meta charset="UTF-8">  
<title>菜单</title>  
<script>  
function fillform(row){  
    document.forms[0].foodid.value = row.children[0].innerText;  
    document.forms[0].foodname.value = row.children[1].innerText;  
    document.forms[0].fooddescribe.value = row.children[2].innerText;  
    // 注意处理价格，可能需要移除货币符号或逗号  
    document.forms[0].foodprice.value = row.children[3].innerText.replace(/[^\d.]/g, '');  
}  
</script>  
</head>  
<body>  
  
<h1>菜单</h1>  
  
<a href="edit.jsp">新增菜品</a>  
  
<table width='100%' border='1'>  
<tr>  
    <th>foodid</th>
    <th>foodname</th>  
    <th>fooddescribe</th>  
    <th>foodprice</th>  
    <th width="100">操作</th>  
</tr>  
<%  
javax.sql.rowset.WebRowSet rs = com.myweb.DBTools.getRS("SELECT * FROM shoppingcart");  
while(rs.next()){  
%>  
<tr onclick="fillform(this)" style="cursor:pointer">  
    <td><%=rs.getString("foodid")%></td>  
    <td><%=rs.getString("foodname")%></td>  
    <td><%=rs.getString("fooddescribe")%></td>  
    <td><%=rs.getString("foodprice")%></td> <!-- 这里可能需要根据实际显示来格式化价格 -->  
    <td><%=rs.getString("deskid")%></td> <!-- 注意：您可能不需要在表格中显示 deskid -->  
    <td>  
        <a href="edit.jsp?id=<%=rs.getString("foodid") %>">修改</a>  
        <a href="save.jsp?btn=del&id=<%=rs.getString("foodid") %>" onclick="return confirm('请确认是否删除当前记录');">删除</a>  
    </td>  
</tr>  
<%  
}  
rs.close();  
%>  
</table>  
  
<form action="save.jsp" method="post">  
    <label for="foodid">foodid</label>  
    <input type="text" id="foodid" name="foodid"><br>  
    <label for="foodname">菜品名</label>  
    <input type="text" id="foodname" name="foodname"><br>  
    <label for="fooddescribe">详情</label>  
    <input type="text" id="fooddescribe" name="fooddescribe"><br>  
    <label for="foodprice">价格</label>  
    <input type="number" id="foodprice" name="foodprice"><br>  
    <input type="submit" name="btn" value="修改">  
    <input type="submit" name="btn" value="新增"><br>  
</form>  
  
</body>  
</html>